﻿<UserControl x:Class="BuyTicket.Views.BoardView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vm="clr-namespace:BuyTicket.ViewModels"
             d:DesignHeight="406"
             d:DesignWidth="547"
             mc:Ignorable="d" Loaded="UserControl_Loaded">
    <UserControl.DataContext>
        <vm:BoardViewModel Loading="BoardViewModel_Loading" Loaded="BoardViewModel_Loaded"/>
    </UserControl.DataContext>
    <DockPanel>
        <Border x:Name="myError"
                Background="Red"
                DockPanel.Dock="Top" Visibility="Collapsed">
            <Label HorizontalAlignment="Center" Foreground="Blue">正在加载，请稍后...</Label>
        </Border>
        <Border x:Name="myTool"  Height="30" DockPanel.Dock="Top">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="80" />
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Content="返回上一步" Click="Button_Click"/>
                <Button Grid.Column="1"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        Command="{Binding RefreshCommand}"
                        Content="刷新" Name="myRefresh" />
                <CheckBox Grid.Column="2"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          Content="自动刷新"
                          IsChecked="{Binding IsAutoRefresh}" />
                <Label  Grid.Column="1"   HorizontalAlignment="Center" VerticalAlignment="Center" >
                    <Hyperlink Click="Hyperlink_Click">跳转至浏览器打开</Hyperlink>
                </Label>
            </Grid>
        </Border>
        <ListView ItemsSource="{Binding Tickets}">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Width="60" Header="车次"  DisplayMemberBinding="{Binding No}"/>
                        <GridViewColumn Width="160" Header="始发" DisplayMemberBinding="{Binding Start}"/>
                        <GridViewColumn Width="160" Header="终点" DisplayMemberBinding="{Binding End}"/>
                        <GridViewColumn Width="60" Header="余票"  DisplayMemberBinding="{Binding Count}"/>
                        <GridViewColumn Width="100" Header="订票">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Command="{Binding Path=OrderCommand}"
                                            Content="预定" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
</UserControl>
